home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disk User Volume 4 #11
/
Commodore_Disk_User_Vol.4_11_1991_-.d64
/
8 way scroll asm
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
7KB
|
427 lines
10 *=49152
11 !
12 ! disable interupts,set up
13 ! interupt vector,enable raster
14 ! interupt,set up vic banks,
15 ! disable hardware timer a,
16 ! re-enable interupts.
17 !
20 setint sei
30 lda #<intr
40 sta 788
50 lda #>intr
60 sta 789
70 lda 53274
80 ora #1
90 sta 53274
100 lda 53265
110 and #127
120 sta 53265
130 lda #252
140 sta 53266
150 lda 56578
160 ora #3
170 sta 56578
180 lda 56576
190 and #252
200 ora #2
210 sta 56576
220 lda 56334
230 and #254
240 sta 56334
250 cli
251 !
252 ! set screen colours,
253 ! set start values to be
254 ! stored in map & map+1
255 ! (see window)
256 !
260 lda #0
270 sta 53280
280 sta 53281
290 lda #<32768
300 sta map
310 lda #>32768
320 sta map+1
997 !
998 rts
1000 !
1001 ! check to see if a scroll
1002 ! is taking place.if not jump
1003 ! to 'noscroll' otherwise
1004 ! check to see which of the 8
1005 ! possible directions we are
1006 ! scrolling in and process.
1007 !
1020 intr lda way
1030 beq noscroll
1040 cmp #1
1050 bne w1
1060 jsr ysub
1070 jmp noscroll
1080 w1 cmp #2
1090 bne w2
1100 jsr yadd
1110 jmp noscroll
1120 w2 cmp #3
1130 bne w3
1140 jsr xsub
1150 jmp noscroll
1160 w3 cmp #4
1170 bne w4
1179 jsr xadd
1180 jmp noscroll
1181 w4 cmp #5
1182 bne w5
1183 jsr xadd
1184 jsr ysub
1185 jmp noscroll
1186 w5 cmp #6
1187 bne w6
1188 jsr ysub
1189 jsr xsub
1190 jmp noscroll
1191 w6 cmp #7
1192 bne w7
1193 jsr yadd
1194 jsr xadd
1195 jmp noscroll
1196 w7 cmp #8
1197 bne noscroll
1198 jsr yadd
1199 jsr xsub
1200 !
1210 ! set up location of raster
1211 ! split and re-vector the
1212 ! interupt to process the
1213 ! status line (non moving
1214 ! screen) routine.
1215 !
1240 noscroll lda #<statline
1250 sta 788
1260 lda #>statline
1270 sta 789
1280 lda raster
1290 sta 53266
1300 jmp exint
1301 !
1302 ! set 40 column screen,
1303 ! clear scroll registers to
1304 ! ensure this section of the
1305 ! screen is still,re-vector
1306 ! the interupt to process the
1307 ! routine dealing with the
1308 ! scrolling section of the
1309 ! screen,jsr to 'control' routine
1310 !
1315 statline lda #8
1320 sta 53270
1330 lda #23
1340 sta 53265
1350 lda #54
1360 sta 53272
1370 lda #<gamearea
1380 sta 788
1390 lda #>gamearea
1400 sta 789
1405 lda #7
1406 sta 53280
1410 jsr control
1415 lda #0
1416 sta 53280
1420 lda #252
1430 sta 53266
1440 jmp exint
1441 !
1442 ! set 38 column,24 row screen
1443 ! print up screen from
1444 ! map & map+1,set values of
1445 ! scroll registers.
1446 !
1450 gamearea lda 53270
1455 and #0
1456 ora #16
1470 ora xscroll
1480 sta 53270
1490 lda 53265
1500 and #248
1510 ora yscroll
1520 sta 53265
1610 lda #36
1620 sta 53272
1625 lda #6
1626 sta 53280
1650 jsr window
1651 lda #0
1652 sta 53280
1654 jmp intr
1655 !
1656 ! signal that interupt has been
1657 ! processed,restore registers
1658 ! and return from interupt.
1659 !
1660 exint lda #1
1670 sta $d019
1690 pla
1700 tay
1710 pla
1720 tax
1730 pla
1740 rti
1741 !
1742 ! hardware scroll screen 1 pixel
1743 ! to the right.if screen has
1744 ! moved more than 1 char. then
1745 ! subtract 1 from 16 bit value in
1746 ! map & map+1.
1747 !
1750 xadd lda 53270
1760 ora #248
1770 clc
1780 adc xspeed
1790 and #7
1800 sta xscroll
1810 bcc exxadd
1820 sec
1830 lda map
1840 sbc #1
1850 sta map
1860 lda map+1
1870 sbc #0
1880 sta map+1
1960 exxadd rts
1961 !
1962 ! hardware scroll screen 1 pixel
1963 ! to the left.if screen has
1964 ! moved more than 1 char. then
1965 ! add 1 to 16 bit value
1966 ! in map & map+1.
1967 !
1970 xsub lda 53270
1980 and #7
1990 sec
2000 sbc xspeed
2010 and #7
2020 sta xscroll
2030 bcs exxsub
2040 clc
2050 lda map
2060 adc #1
2070 sta map
2080 lda map+1
2090 adc #0
2100 sta map+1
2180 exxsub rts
2181 !
2182 ! hardware scroll the screen
2183 ! down 1 pixel. if screen has
2184 ! moved more than 1 char then
2185 ! subtract number of screens
2186 ! horizontally in map multiplyed
2187 ! by 40 from 16 bit value in
2188 ! map & map+1.
2189 ! eg:-
2190 ! if there are 6 screen across
2191 ! in map then subtract 240.
2192 !
2199 yadd lda 53265
2200 ora #248
2210 clc
2220 adc yspeed
2230 and #7
2240 sta yscroll
2250 bcc exyadd
2260 sec
2270 lda map
2280 sbc #240
2290 sta map
2300 lda map+1
2310 sbc #0
2320 sta map+1
2400 exyadd rts
2401 !
2402 ! as above but scroll up 1 pixel
2403 ! and add same value if
2404 ! necessary.
2405 !
2410 ysub lda 53265
2420 and #7
2430 sec
2440 sbc yspeed
2450 and #7
2460 sta yscroll
2470 bcs exysub
2480 clc
2490 lda map
2500 adc #240
2510 sta map
2520 lda map+1
2530 adc #0
2540 sta map+1
2620 exysub rts
4000 !
4001 ! (see diagram 1 ):-
4002 ! print up 1000 bytes to screen,
4003 ! ( screen is at 17408),
4004 ! starting at memory location
4005 ! pointed at by values in
4006 ! map & map+1.
4007 !
4070 window lda #<18432
4080 sta 253
4090 lda #>18432
4100 sta 254
4120 lda map
4130 sta 251
4140 lda map+1
4150 sta 252
4160 ldx #18
4180 windloop1 ldy #0
4190 windloop2 lda (251),y
4200 sta (253),y
4210 iny
4215 cpy #40
4220 bne windloop2
4230 lda 251
4240 clc
4250 adc #240
4260 sta 251
4270 bcc windlp2
4290 inc 252
4300 windlp2 lda 253
4310 clc
4320 adc #40
4330 sta 253
4340 bcc excal
4360 inc 254
4370 excal dex
4376 bne windloop1
4390 rts
4400 !
4410 ! variables as follows :-
4411 !
4412 ! 1 - lo,hi address of screen
4413 ! (row 0,column 0) in overall map
4414 ! 2 - posistion of raster split
4415 ! 3 - speed of x scroll
4416 ! 4 - speed of y scroll
4417 ! 5 - value of x scroll register
4418 ! 6 - value of y scroll register
4419 ! 7 - joystick x value
4420 ! 8 - joystick y value
4421 ! 9 - direction of scroll (0-8)
4422 !
6000 map byt <32768,>32768
6030 raster byt 189
6060 xspeed byt 1
6070 yspeed byt 1
6080 xscroll byt 0
6090 yscroll byt 0
6100 dx byt 0
6110 dy byt 0
6160 way byt 0
6161 !
6162 ! the values in way indicate
6163 ! the follwing:-
6164 !
6165 ! 0 = no scrolling
6166 ! 1 = scroll up
6167 ! 2 = scroll down
6168 ! 3 = scroll left
6169 ! 4 = scroll right
6170 ! 5 = scroll up & right
6171 ! 6 = scroll up & left
6172 ! 7 = scroll down & right
6173 ! 8 = scroll down & left
6174 !
6179 !
6180 ! joystick reading routine.
6181 ! see page 345 of programmers
6182 ! reference guide for full
6183 ! explanation.
6184 !
7000 joyread lda 56320
7010 ldy #0
7020 ldx #0
7025 !
7030 lsr a
7040 bcs joy0
7050 dey
7060 joy0 lsr a
7070 bcs joy1
7080 iny
7090 joy1 lsr a
7100 bcs joy2
7110 dex
7120 joy2 lsr a
7130 bcs joy3
7140 inx
7150 joy3 lsr a
7160 stx dx
7170 sty dy
7180 rts
7190 !
7191 ! main control routine :-
7192 ! decide which direction to
7193 ! scroll.
7194 !
8000 control jsr joyread
8010 ldx dx
8020 ldy dy
8021 txa
8022 bne vertical
8023 tya
8024 bne vertical
8025 sta way
8026 rts
8030 vertical cpx #0
8040 bne horizontal
8050 upc cpy #255
8060 bne downc
8070 lda #2
8080 sta way
8090 rts
8100 downc cpy #1
8110 bne xvert
8120 lda #1
8130 sta way
8140 xvert rts
8150 horizontal cpy #0
8160 bne dia(NULL)nal
8170 leftc cpx #255
8180 bne rightc
8190 lda #4
8200 sta way
8210 rts
8220 rightc cpx #1
8230 bne outcon
8240 lda #3
8250 sta way
8260 outcon rts
8270 dia(NULL)nal cpy #255
8280 bne diagdown
8290 cpx #1
8300 bne uplft
8310 uprght lda #8
8320 sta way
8330 rts
8340 uplft cpx #255
8350 bne outcon
8360 lda #7
8370 sta way
8380 rts
8390 diagdown cpy #1
8400 bne xdiag
8410 cpx #1
8420 bne dwnlft
8440 dwnrght lda #6
8450 sta way
8460 rts
8470 dwnlft cpx #255
8480 bne xdiag
8490 lda #5
8500 sta way
8510 xdiag rts
8520 !
8530 end